package yawning.mew.pivot;

import java.io.IOException;

import org.apache.pivot.beans.BXML;
import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.collections.LinkedList;
import org.apache.pivot.collections.List;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.TableView;
import org.apache.pivot.wtk.TextArea;

public class MewPivotRSV {
	private Component mComponent;
	@BXML private TableView rsvView;
	@BXML private TextArea pawnOutput;

	public MewPivotRSV() {
		// Setup the ui.
		BXMLSerializer bxmlSerializer = new BXMLSerializer();
		try {
			mComponent = (Component) bxmlSerializer.readObject(getClass().getResource("MewPivotRSV.bxml"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SerializationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		bxmlSerializer.bind(this);
	}

	public Component getComponent() {
		return mComponent;
	}

	public void clearPawnString() {
		pawnOutput.setText("");
	}

	public void setPawnString(String s) {
		pawnOutput.setText(s);
	}

	public void clearRsvTableData() {
		rsvView.setTableData(new LinkedList<Object>());
	}

	public void setRsvTableData(List<?> tableData, String reportStatName) {
		rsvView.setTableData(tableData);
		rsvView.getColumns().get(1).setHeaderData(reportStatName);
	}

	public TableView getRsvView() {
		return rsvView;
	}

	public TextArea getPawnOutput() {
		return pawnOutput;
	}
}
